#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <unistd.h>
#include <unistd.h>

int main()
{
    //有点像就近原则
    umask(0);

    int fd = open("log.txt", O_RDONLY);

    if(fd < 0)
    {
        perror("open");

        return 1;
    }

    printf("fd : %d\n", fd);

    char buffer[128];
    size_t s = read(fd, buffer, sizeof(buffer) - 1);
    if(s > 0)
    {
        buffer[s] = '\0';
        printf("%s", buffer);
    }
    return 0;
}

